<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" />
<title>Matplotlib tutorial</title>
<link rel="stylesheet" href="dana.css" type="text/css" />
</head>
<body>
<div class="document" id="matplotlib-tutorial">
<h1 class="title">Matplotlib tutorial</h1>
<h2 class="subtitle" id="nicolas-p-rougier">Nicolas P. Rougier</h2>

<a class="reference external image-reference" href="http://dx.doi.org/10.5281/zenodo.28747"><img alt="https://zenodo.org/badge/doi/10.5281/zenodo.28747.png" src="https://zenodo.org/badge/doi/10.5281/zenodo.28747.png" /></a>
<div class="contents local topic" id="table-of-contents">
<p class="topic-title first">Table of Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#introduction" id="id4">Introduction</a></li>
<li><a class="reference internal" href="#simple-plot" id="id5">Simple plot</a></li>
<li><a class="reference internal" href="#figures-subplots-axes-and-ticks" id="id6">Figures, Subplots, Axes and Ticks</a></li>
<li><a class="reference internal" href="#animation" id="id7">Animation</a></li>
<li><a class="reference internal" href="#other-types-of-plots" id="id8">Other Types of Plots</a></li>
<li><a class="reference internal" href="#beyond-this-tutorial" id="id9">Beyond this tutorial</a></li>
<li><a class="reference internal" href="#quick-references" id="id10">Quick references</a></li>
</ul>
</div>
<p>Sources are available from
<a class="reference external" href="https://github.com/rougier/matplotlib-tutorial">github</a></p>
<p>All code and material is licensed under a <a class="reference external" href="http://creativecommons.org/licenses/by-sa/4.0">Creative Commons
Attribution-ShareAlike 4.0</a>.</p>
<p>You can test your installation before the tutorial using the <a class="reference external" href="scripts/check-installation.py">check-installation.py</a> script.</p>
<p>Tutorial can be read at <a class="reference external" href="http://www.labri.fr/perso/nrougier/teaching/matplotlib/matplotlib.html">http://www.labri.fr/perso/nrougier/teaching/matplotlib/matplotlib.html</a></p>
<p>See also:</p>
<ul class="simple">
<li><a class="reference external" href="http://www.labri.fr/perso/nrougier/teaching/numpy/numpy.html">Numpy tutorial</a></li>
<li><a class="reference external" href="http://www.labri.fr/perso/nrougier/teaching/numpy.100/index.html">100 Numpy exercices</a></li>
<li><a class="reference external" href="http://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1003833">Ten simple rules for better figures</a></li>
</ul>
<div class="section" id="introduction">
<h1><a class="toc-backref" href="#id4">Introduction</a></h1>
<p>matplotlib is probably the single most used Python package for 2D-graphics. It
provides both a very quick way to visualize data from Python and
publication-quality figures in many formats.  We are going to explore
matplotlib in interactive mode covering most common cases.</p>
<div class="section" id="ipython">
<h2>IPython</h2>
<p><a class="reference external" href="http://ipython.org/">IPython</a> is an enhanced interactive Python shell that
has lots of interesting features including named inputs and outputs, access to
shell commands, improved debugging and many more. It allows
interactive matplotlib sessions that have Matlab/Mathematica-like functionality.</p>
</div>
<div class="section" id="pyplot">
<h2>pyplot</h2>
<p>pyplot provides a convenient interface to the matplotlib object-oriented
plotting library. It is modeled closely after Matlab(TM). Therefore, the
majority of plotting commands in pyplot have Matlab(TM) analogs with similar
arguments. Important commands are explained with interactive examples.</p>
</div>
</div>
<div class="section" id="simple-plot">
<h1><a class="toc-backref" href="#id5">Simple plot</a></h1>
<p>In this section, we want to draw the cosine and sine functions on the same
plot. Starting from the default settings, we'll enrich the figure step by step
to make it nicer.</p>
<p>First step is to get the data for the sine and cosine functions:</p>
<pre class="literal-block">
import numpy as np

X = np.linspace(-np.pi, np.pi, 256,endpoint=True)
C,S = np.cos(X), np.sin(X)
</pre>
<p>X is now a numpy array with 256 values ranging from -π to +π (included). C is
the cosine (256 values) and S is the sine (256 values).</p>
<p>To run the example, you can download each of the examples and run it using:</p>
<pre class="literal-block">
$ python exercice_1.py
</pre>
<p>You can get source for each step by clicking on the corresponding figure.</p>
<div class="section" id="using-defaults">
<h2>Using defaults</h2>
<div class="admonition-documentation admonition">
<p class="first admonition-title">Documentation</p>
<ul class="last simple">
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/pyplot_tutorial.html">plot tutorial</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.plot">plot() command</a></li>
</ul>
</div>
<a class="reference external image-reference" href="scripts/exercice_1.py"><img alt="figures/exercice_1.png" class="align-right" src="figures/exercice_1.png" /></a>
<p>Matplotlib comes with a set of default settings that allow customizing all
kinds of properties. You can control the defaults of almost every property in
matplotlib: figure size and dpi, line width, color and style, axes, axis and
grid properties, text and font properties and so on. While matplotlib defaults
are rather good in most cases, you may want to modify some properties for
specific cases.</p>
<pre class="code python literal-block">
<span class="keyword namespace">import</span> <span class="name namespace">numpy</span> <span class="keyword namespace">as</span> <span class="name namespace">np</span>
<span class="keyword namespace">import</span> <span class="name namespace">matplotlib.pyplot</span> <span class="keyword namespace">as</span> <span class="name namespace">plt</span>

<span class="name">X</span> <span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">linspace</span><span class="punctuation">(</span><span class="operator">-</span><span class="name">np</span><span class="operator">.</span><span class="name">pi</span><span class="punctuation">,</span> <span class="name">np</span><span class="operator">.</span><span class="name">pi</span><span class="punctuation">,</span> <span class="literal number integer">256</span><span class="punctuation">,</span> <span class="name">endpoint</span><span class="operator">=</span><span class="name builtin pseudo">True</span><span class="punctuation">)</span>
<span class="name">C</span><span class="punctuation">,</span><span class="name">S</span> <span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">cos</span><span class="punctuation">(</span><span class="name">X</span><span class="punctuation">),</span> <span class="name">np</span><span class="operator">.</span><span class="name">sin</span><span class="punctuation">(</span><span class="name">X</span><span class="punctuation">)</span>

<span class="name">plt</span><span class="operator">.</span><span class="name">plot</span><span class="punctuation">(</span><span class="name">X</span><span class="punctuation">,</span><span class="name">C</span><span class="punctuation">)</span>
<span class="name">plt</span><span class="operator">.</span><span class="name">plot</span><span class="punctuation">(</span><span class="name">X</span><span class="punctuation">,</span><span class="name">S</span><span class="punctuation">)</span>

<span class="name">plt</span><span class="operator">.</span><span class="name">show</span><span class="punctuation">()</span>
</pre>
</div>
<div class="section" id="instantiating-defaults">
<h2>Instantiating defaults</h2>
<div class="admonition-documentation admonition">
<p class="first admonition-title">Documentation</p>
<ul class="last simple">
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/customizing.html">Customizing matplotlib</a></li>
</ul>
</div>
<a class="reference external image-reference" href="scripts/exercice_2.py"><img alt="figures/exercice_2.png" class="align-right" src="figures/exercice_2.png" /></a>
<p>In the script below, we've instantiated (and commented) all the figure settings
that influence the appearance of the plot. The settings have been explicitly
set to their default values, but now you can interactively play with the values
to explore their affect (see <a class="reference internal" href="#line-properties">Line properties</a> and <a class="reference internal" href="#line-styles">Line styles</a> below).</p>
<pre class="code python literal-block">
<span class="comment single"># Imports</span>
<span class="keyword namespace">import</span> <span class="name namespace">numpy</span> <span class="keyword namespace">as</span> <span class="name namespace">np</span>
<span class="keyword namespace">import</span> <span class="name namespace">matplotlib.pyplot</span> <span class="keyword namespace">as</span> <span class="name namespace">plt</span>

<span class="comment single"># Create a new figure of size 8x6 points, using 100 dots per inch</span>
<span class="name">plt</span><span class="operator">.</span><span class="name">figure</span><span class="punctuation">(</span><span class="name">figsize</span><span class="operator">=</span><span class="punctuation">(</span><span class="literal number integer">8</span><span class="punctuation">,</span><span class="literal number integer">6</span><span class="punctuation">),</span> <span class="name">dpi</span><span class="operator">=</span><span class="literal number integer">80</span><span class="punctuation">)</span>

<span class="comment single"># Create a new subplot from a grid of 1x1</span>
<span class="name">plt</span><span class="operator">.</span><span class="name">subplot</span><span class="punctuation">(</span><span class="literal number integer">111</span><span class="punctuation">)</span>

<span class="name">X</span> <span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">linspace</span><span class="punctuation">(</span><span class="operator">-</span><span class="name">np</span><span class="operator">.</span><span class="name">pi</span><span class="punctuation">,</span> <span class="name">np</span><span class="operator">.</span><span class="name">pi</span><span class="punctuation">,</span> <span class="literal number integer">256</span><span class="punctuation">,</span><span class="name">endpoint</span><span class="operator">=</span><span class="name builtin pseudo">True</span><span class="punctuation">)</span>
<span class="name">C</span><span class="punctuation">,</span><span class="name">S</span> <span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">cos</span><span class="punctuation">(</span><span class="name">X</span><span class="punctuation">),</span> <span class="name">np</span><span class="operator">.</span><span class="name">sin</span><span class="punctuation">(</span><span class="name">X</span><span class="punctuation">)</span>

<span class="comment single"># Plot cosine using blue color with a continuous line of width 1 (pixels)</span>
<span class="name">plt</span><span class="operator">.</span><span class="name">plot</span><span class="punctuation">(</span><span class="name">X</span><span class="punctuation">,</span> <span class="name">C</span><span class="punctuation">,</span> <span class="name">color</span><span class="operator">=</span><span class="literal string double">&quot;blue&quot;</span><span class="punctuation">,</span> <span class="name">linewidth</span><span class="operator">=</span><span class="literal number float">1.0</span><span class="punctuation">,</span> <span class="name">linestyle</span><span class="operator">=</span><span class="literal string double">&quot;-&quot;</span><span class="punctuation">)</span>

<span class="comment single"># Plot sine using green color with a continuous line of width 1 (pixels)</span>
<span class="name">plt</span><span class="operator">.</span><span class="name">plot</span><span class="punctuation">(</span><span class="name">X</span><span class="punctuation">,</span> <span class="name">S</span><span class="punctuation">,</span> <span class="name">color</span><span class="operator">=</span><span class="literal string double">&quot;green&quot;</span><span class="punctuation">,</span> <span class="name">linewidth</span><span class="operator">=</span><span class="literal number float">1.0</span><span class="punctuation">,</span> <span class="name">linestyle</span><span class="operator">=</span><span class="literal string double">&quot;-&quot;</span><span class="punctuation">)</span>

<span class="comment single"># Set x limits</span>
<span class="name">plt</span><span class="operator">.</span><span class="name">xlim</span><span class="punctuation">(</span><span class="operator">-</span><span class="literal number float">4.0</span><span class="punctuation">,</span><span class="literal number float">4.0</span><span class="punctuation">)</span>

<span class="comment single"># Set x ticks</span>
<span class="name">plt</span><span class="operator">.</span><span class="name">xticks</span><span class="punctuation">(</span><span class="name">np</span><span class="operator">.</span><span class="name">linspace</span><span class="punctuation">(</span><span class="operator">-</span><span class="literal number integer">4</span><span class="punctuation">,</span><span class="literal number integer">4</span><span class="punctuation">,</span><span class="literal number integer">9</span><span class="punctuation">,</span><span class="name">endpoint</span><span class="operator">=</span><span class="name builtin pseudo">True</span><span class="punctuation">))</span>

<span class="comment single"># Set y limits</span>
<span class="name">plt</span><span class="operator">.</span><span class="name">ylim</span><span class="punctuation">(</span><span class="operator">-</span><span class="literal number float">1.0</span><span class="punctuation">,</span><span class="literal number float">1.0</span><span class="punctuation">)</span>

<span class="comment single"># Set y ticks</span>
<span class="name">plt</span><span class="operator">.</span><span class="name">yticks</span><span class="punctuation">(</span><span class="name">np</span><span class="operator">.</span><span class="name">linspace</span><span class="punctuation">(</span><span class="operator">-</span><span class="literal number integer">1</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">,</span><span class="literal number integer">5</span><span class="punctuation">,</span><span class="name">endpoint</span><span class="operator">=</span><span class="name builtin pseudo">True</span><span class="punctuation">))</span>

<span class="comment single"># Save figure using 72 dots per inch</span>
<span class="comment single"># savefig(&quot;../figures/exercice_2.png&quot;,dpi=72)</span>

<span class="comment single"># Show result on screen</span>
<span class="name">plt</span><span class="operator">.</span><span class="name">show</span><span class="punctuation">()</span>
</pre>
</div>
<div class="section" id="changing-colors-and-line-widths">
<h2>Changing colors and line widths</h2>
<div class="admonition-documentation admonition">
<p class="first admonition-title">Documentation</p>
<ul class="last simple">
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/pyplot_tutorial.html#controlling-line-properties">Controlling line properties</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.lines.Line2D">Line API</a></li>
</ul>
</div>
<a class="reference external image-reference" href="scripts/exercice_3.py"><img alt="figures/exercice_3.png" class="align-right" src="figures/exercice_3.png" /></a>
<p>First step, we want to have the cosine in blue and the sine in red and a
slightly thicker line for both of them. We'll also slightly alter the figure
size to make it more horizontal.</p>
<pre class="literal-block">
...
plt.figure(figsize=(10,6), dpi=80)
plt.plot(X, C, color=&quot;blue&quot;, linewidth=2.5, linestyle=&quot;-&quot;)
plt.plot(X, S, color=&quot;red&quot;,  linewidth=2.5, linestyle=&quot;-&quot;)
...
</pre>
</div>
<div class="section" id="setting-limits">
<h2>Setting limits</h2>
<div class="admonition-documentation admonition">
<p class="first admonition-title">Documentation</p>
<ul class="last simple">
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.xlim">xlim() command</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.ylim">ylim() command</a></li>
</ul>
</div>
<a class="reference external image-reference" href="scripts/exercice_4.py"><img alt="figures/exercice_4.png" class="align-right" src="figures/exercice_4.png" /></a>
<p>Current limits of the figure are a bit too tight and we want to make some space
in order to clearly see all data points.</p>
<pre class="literal-block">
...
plt.xlim(X.min()*1.1, X.max()*1.1)
plt.ylim(C.min()*1.1, C.max()*1.1)
...
</pre>
</div>
<div class="section" id="setting-ticks">
<h2>Setting ticks</h2>
<div class="admonition-documentation admonition">
<p class="first admonition-title">Documentation</p>
<ul class="last simple">
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.xticks">xticks() command</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.yticks">yticks() command</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/artists.html#axis-container">Tick container</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/ticker_api.html">Tick locating and formatting</a></li>
</ul>
</div>
<a class="reference external image-reference" href="scripts/exercice_5.py"><img alt="figures/exercice_5.png" class="align-right" src="figures/exercice_5.png" /></a>
<p>Current ticks are not ideal because they do not show the interesting values
(+/-π,+/-π/2) for sine and cosine. We'll change them such that they show only
these values.</p>
<pre class="literal-block">
...
plt.xticks( [-np.pi, -np.pi/2, 0, np.pi/2, np.pi])
plt.yticks([-1, 0, +1])
...
</pre>
</div>
<div class="section" id="setting-tick-labels">
<h2>Setting tick labels</h2>
<div class="admonition-documentation admonition">
<p class="first admonition-title">Documentation</p>
<ul class="last simple">
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/index_text.html">Working with text</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.xticks">xticks() command</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.yticks">yticks() command</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/axes_api.html?#matplotlib.axes.Axes.set_xticklabels">set_xticklabels()</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/axes_api.html?#matplotlib.axes.Axes.set_yticklabels">set_yticklabels()</a></li>
</ul>
</div>
<a class="reference external image-reference" href="scripts/exercice_6.py"><img alt="figures/exercice_6.png" class="align-right" src="figures/exercice_6.png" /></a>
<p>Ticks are now properly placed but their label is not very explicit. We could
guess that 3.142 is π but it would be better to make it explicit. When we set
tick values, we can also provide a corresponding label in the second argument
list. Note that we'll use latex to allow for nice rendering of the label.</p>
<pre class="literal-block">
...
plt.xticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi],
       [r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$'])

plt.yticks([-1, 0, +1],
       [r'$-1$', r'$0$', r'$+1$'])
...
</pre>
</div>
<div class="section" id="moving-spines">
<h2>Moving spines</h2>
<div class="admonition-documentation admonition">
<p class="first admonition-title">Documentation</p>
<ul class="last simple">
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/spines_api.html#matplotlib.spines">Spines</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/artists.html#axis-container">Axis container</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/transforms_tutorial.html">Transformations tutorial</a></li>
</ul>
</div>
<a class="reference external image-reference" href="scripts/exercice_7.py"><img alt="figures/exercice_7.png" class="align-right" src="figures/exercice_7.png" /></a>
<p>Spines are the lines connecting the axis tick marks and noting the boundaries
of the data area. They can be placed at arbitrary positions and until now, they
were on the border of the axis. We'll change that since we want to have them in
the middle. Since there are four of them (top/bottom/left/right), we'll discard
the top and right by setting their color to none and we'll move the bottom and
left ones to coordinate 0 in data space coordinates.</p>
<pre class="literal-block">
...
ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.spines['bottom'].set_position(('data',0))
ax.yaxis.set_ticks_position('left')
ax.spines['left'].set_position(('data',0))
...
</pre>
</div>
<div class="section" id="adding-a-legend">
<h2>Adding a legend</h2>
<div class="admonition-documentation admonition">
<p class="first admonition-title">Documentation</p>
<ul class="last simple">
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/legend_guide.html">Legend guide</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.legend">legend() command</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/legend_api.html#matplotlib.legend.Legend">Legend API</a></li>
</ul>
</div>
<a class="reference external image-reference" href="scripts/exercice_8.py"><img alt="figures/exercice_8.png" class="align-right" src="figures/exercice_8.png" /></a>
<p>Let's add a legend in the upper left corner. This only requires adding the
keyword argument label (that will be used in the legend box) to the plot
commands.</p>
<pre class="literal-block">
...
plt.plot(X, C, color=&quot;blue&quot;, linewidth=2.5, linestyle=&quot;-&quot;, label=&quot;cosine&quot;)
plt.plot(X, S, color=&quot;red&quot;,  linewidth=2.5, linestyle=&quot;-&quot;, label=&quot;sine&quot;)

plt.legend(loc='upper left', frameon=False)
...
</pre>
</div>
<div class="section" id="annotate-some-points">
<h2>Annotate some points</h2>
<div class="admonition-documentation admonition">
<p class="first admonition-title">Documentation</p>
<ul class="last simple">
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/annotations_guide.html">Annotating axis</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.annotate">annotate() command</a></li>
</ul>
</div>
<a class="reference external image-reference" href="scripts/exercice_9.py"><img alt="figures/exercice_9.png" class="align-right" src="figures/exercice_9.png" /></a>
<p>Let's annotate some interesting points using the annotate command. We chose the
2π/3 value and we want to annotate both the sine and the cosine. We'll first
draw a marker on the curve as well as a straight dotted line. Then, we'll use
the annotate command to display some text with an arrow.</p>
<pre class="literal-block">
...

t = 2*np.pi/3
plt.plot([t,t],[0,np.cos(t)], color ='blue', linewidth=1.5, linestyle=&quot;--&quot;)
plt.scatter([t,],[np.cos(t),], 50, color ='blue')

plt.annotate(r'$\sin(\frac{2\pi}{3})=\frac{\sqrt{3}}{2}$',
             xy=(t, np.sin(t)), xycoords='data',
             xytext=(+10, +30), textcoords='offset points', fontsize=16,
             arrowprops=dict(arrowstyle=&quot;-&gt;&quot;, connectionstyle=&quot;arc3,rad=.2&quot;))

plt.plot([t,t],[0,np.sin(t)], color ='red', linewidth=1.5, linestyle=&quot;--&quot;)
plt.scatter([t,],[np.sin(t),], 50, color ='red')

plt.annotate(r'$\cos(\frac{2\pi}{3})=-\frac{1}{2}$',
             xy=(t, np.cos(t)), xycoords='data',
             xytext=(-90, -50), textcoords='offset points', fontsize=16,
             arrowprops=dict(arrowstyle=&quot;-&gt;&quot;, connectionstyle=&quot;arc3,rad=.2&quot;))
...
</pre>
</div>
<div class="section" id="devil-is-in-the-details">
<h2>Devil is in the details</h2>
<div class="admonition-documentation admonition">
<p class="first admonition-title">Documentation</p>
<ul class="last simple">
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/artist_api.html">Artists</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.text.Text.set_bbox">BBox</a></li>
</ul>
</div>
<a class="reference external image-reference" href="scripts/exercice_10.py"><img alt="figures/exercice_10.png" class="align-right" src="figures/exercice_10.png" /></a>
<p>The tick labels are now hardly visible because of the blue and red lines. We can
make them bigger and we can also adjust their properties such that they'll be
rendered on a semi-transparent white background. This will allow us to see both
the data and the labels.</p>
<pre class="literal-block">
...
for label in ax.get_xticklabels() + ax.get_yticklabels():
    label.set_fontsize(16)
    label.set_bbox(dict(facecolor='white', edgecolor='None', alpha=0.65 ))
...
</pre>
</div>
</div>
<div class="section" id="figures-subplots-axes-and-ticks">
<h1><a class="toc-backref" href="#id6">Figures, Subplots, Axes and Ticks</a></h1>
<p>So far we have used implicit figure and axes creation. This is handy for fast
plots. We can have more control over the display using figure, subplot, and
axes explicitly. A figure in matplotlib means the whole window in the user
interface. Within this figure there can be subplots. While subplot positions
the plots in a regular grid, axes allows free placement within the figure. Both
can be useful depending on your intention. We've already worked with figures
and subplots without explicitly calling them. When we call plot, matplotlib
calls gca() to get the current axes and gca in turn calls gcf() to get the
current figure. If there is none it calls figure() to make one, strictly
speaking, to make a subplot(111). Let's look at the details.</p>
<div class="section" id="figures">
<h2>Figures</h2>
<p>A figure is the windows in the GUI that has &quot;Figure #&quot; as title. Figures
are numbered starting from 1 as opposed to the normal Python way starting
from 0. This is clearly MATLAB-style.  There are several parameters that
determine what the figure looks like:</p>
<table border="1" class="docutils">
<colgroup>
<col width="17%" />
<col width="28%" />
<col width="54%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Argument</th>
<th class="head">Default</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>num</td>
<td>1</td>
<td>number of figure</td>
</tr>
<tr><td>figsize</td>
<td>figure.figsize</td>
<td>figure size in in inches (width, height)</td>
</tr>
<tr><td>dpi</td>
<td>figure.dpi</td>
<td>resolution in dots per inch</td>
</tr>
<tr><td>facecolor</td>
<td>figure.facecolor</td>
<td>color of the drawing background</td>
</tr>
<tr><td>edgecolor</td>
<td>figure.edgecolor</td>
<td>color of edge around the drawing background</td>
</tr>
<tr><td>frameon</td>
<td>True</td>
<td>draw figure frame or not</td>
</tr>
</tbody>
</table>
<p>The defaults can be specified in the resource file and will be used most of the
time. Only the number of the figure is frequently changed.</p>
<p>When you work with the GUI you can close a figure by clicking on the x in the
upper right corner. But you can close a figure programmatically by calling
close. Depending on the argument it closes (1) the current figure (no
argument), (2) a specific figure (figure number or figure instance as
argument), or (3) all figures (all as argument).</p>
<p>As with other objects, you can set figure properties with the set_something methods.</p>
</div>
<div class="section" id="subplots">
<h2>Subplots</h2>
<p>With subplot you can arrange plots in a regular grid. You need to specify the
number of rows and columns and the number of the plot. Note that the <a class="reference external" href="http://matplotlib.sourceforge.net/users/gridspec.html">gridspec</a> command is a more
powerful alternative.</p>
<a class="reference external image-reference" href="scripts/subplot-horizontal.py"><img alt="figures/subplot-horizontal.png" src="figures/subplot-horizontal.png" /></a>
<a class="reference external image-reference" href="scripts/subplot-vertical.py"><img alt="figures/subplot-vertical.png" src="figures/subplot-vertical.png" /></a>
<a class="reference external image-reference" href="scripts/subplot-grid.py"><img alt="figures/subplot-grid.png" src="figures/subplot-grid.png" /></a>
<a class="reference external image-reference" href="scripts/gridspec.py"><img alt="figures/gridspec.png" src="figures/gridspec.png" /></a>
</div>
<div class="section" id="axes">
<h2>Axes</h2>
<p>Axes are very similar to subplots but allow placement of plots at any location
in the figure. So if we want to put a smaller plot inside a bigger one we do
so with axes.</p>
<a class="reference external image-reference" href="scripts/axes.py"><img alt="figures/axes.png" src="figures/axes.png" /></a>
<a class="reference external image-reference" href="scripts/axes-2.py"><img alt="figures/axes-2.png" src="figures/axes-2.png" /></a>
</div>
<div class="section" id="ticks">
<h2>Ticks</h2>
<p>Well formatted ticks are an important part of publishing-ready
figures. Matplotlib provides a totally configurable system for ticks. There are
tick locators to specify where ticks should appear and tick formatters to give
ticks the appearance you want. Major and minor ticks can be located and
formatted independently from each other. Per default minor ticks are not shown,
i.e. there is only an empty list for them because it is as NullLocator (see
below).</p>
<div class="section" id="tick-locators">
<h3>Tick Locators</h3>
<p>There are several locators for different kind of requirements:</p>
<table border="1" class="docutils">
<colgroup>
<col width="22%" />
<col width="78%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Class</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="docutils literal">NullLocator</tt></td>
<td><p class="first">No ticks.</p>
<img alt="figures/ticks-NullLocator.png" class="last" src="figures/ticks-NullLocator.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">IndexLocator</tt></td>
<td><p class="first">Place a tick on every multiple of some base number of points plotted.</p>
<img alt="figures/ticks-IndexLocator.png" class="last" src="figures/ticks-IndexLocator.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">FixedLocator</tt></td>
<td><p class="first">Tick locations are fixed.</p>
<img alt="figures/ticks-FixedLocator.png" class="last" src="figures/ticks-FixedLocator.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">LinearLocator</tt></td>
<td><p class="first">Determine the tick locations.</p>
<img alt="figures/ticks-LinearLocator.png" class="last" src="figures/ticks-LinearLocator.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">MultipleLocator</tt></td>
<td><p class="first">Set a tick on every integer that is multiple of some base.</p>
<img alt="figures/ticks-MultipleLocator.png" class="last" src="figures/ticks-MultipleLocator.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">AutoLocator</tt></td>
<td><p class="first">Select no more than n intervals at nice locations.</p>
<img alt="figures/ticks-AutoLocator.png" class="last" src="figures/ticks-AutoLocator.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">LogLocator</tt></td>
<td><p class="first">Determine the tick locations for log axes.</p>
<img alt="figures/ticks-LogLocator.png" class="last" src="figures/ticks-LogLocator.png" />
</td>
</tr>
</tbody>
</table>
<p>All of these locators derive from the base class matplotlib.ticker.Locator.
You can make your own locator deriving from it. Handling dates as ticks can be
especially tricky. Therefore, matplotlib provides special locators in
matplotlib.dates.</p>
</div>
</div>
</div>
<div class="section" id="animation">
<h1><a class="toc-backref" href="#id7">Animation</a></h1>
<p>For quite a long time, animation in matplotlib was not an easy task and was
done mainly through clever hacks. However, things have started to change since
version 1.1 and the introduction of tools for creating animation very
intuitively, with the possibility to save them in all kind of formats (but don't
expect to be able to run very complex animation at 60 fps though).</p>
<div class="admonition-documentation admonition">
<p class="first admonition-title">Documentation</p>
<ul class="last simple">
<li>See <a class="reference external" href="http://matplotlib.org/api/animation_api.html">Animation</a></li>
</ul>
</div>
<p>The most easy way to make an animation in matplotlib is to declare a
FuncAnimation object that specifies to matplotlib what is the figure to
update, what is the update function and what is the delay between frames.</p>
<div class="section" id="drip-drop">
<h2>Drip drop</h2>
<p>A very simple rain effect can be obtained by having small growing rings
randomly positioned over a figure. Of course, they won't grow forever since the
wave is supposed to damp with time. To simulate that, we can use a more and
more transparent color as the ring is growing, up to the point where it is no
more visible. At this point, we remove the ring and create a new one.</p>
<p>First step is to create a blank figure:</p>
<pre class="code python literal-block">
<span class="comment single"># New figure with white background</span>
<span class="name">fig</span> <span class="operator">=</span> <span class="name">plt</span><span class="operator">.</span><span class="name">figure</span><span class="punctuation">(</span><span class="name">figsize</span><span class="operator">=</span><span class="punctuation">(</span><span class="literal number integer">6</span><span class="punctuation">,</span><span class="literal number integer">6</span><span class="punctuation">),</span> <span class="name">facecolor</span><span class="operator">=</span><span class="literal string single">'white'</span><span class="punctuation">)</span>

<span class="comment single"># New axis over the whole figure, no frame and a 1:1 aspect ratio</span>
<span class="name">ax</span> <span class="operator">=</span> <span class="name">fig</span><span class="operator">.</span><span class="name">add_axes</span><span class="punctuation">([</span><span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">],</span> <span class="name">frameon</span><span class="operator">=</span><span class="name builtin pseudo">False</span><span class="punctuation">,</span> <span class="name">aspect</span><span class="operator">=</span><span class="literal number integer">1</span><span class="punctuation">)</span>
</pre>
<p>Next, we need to create several rings. For this, we can use the scatter plot
object that is generally used to visualize points cloud, but we can also use it
to draw rings by specifying we don't have a facecolor. We have also to take
care of initial size and color for each ring such that we have all size between
a minimum and a maximum size and also to make sure the largest ring is almost
transparent.</p>
<a class="reference external image-reference" href="scripts/rain-static.py"><img alt="figures/rain-static.png" class="align-right" src="figures/rain-static.png" /></a>
<pre class="code python literal-block">
<span class="comment single"># Number of ring</span>
<span class="name">n</span> <span class="operator">=</span> <span class="literal number integer">50</span>
<span class="name">size_min</span> <span class="operator">=</span> <span class="literal number integer">50</span>
<span class="name">size_max</span> <span class="operator">=</span> <span class="literal number integer">50</span><span class="operator">*</span><span class="literal number integer">50</span>

<span class="comment single"># Ring position</span>
<span class="name">P</span> <span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">random</span><span class="operator">.</span><span class="name">uniform</span><span class="punctuation">(</span><span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">,(</span><span class="name">n</span><span class="punctuation">,</span><span class="literal number integer">2</span><span class="punctuation">))</span>

<span class="comment single"># Ring colors</span>
<span class="name">C</span> <span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">ones</span><span class="punctuation">((</span><span class="name">n</span><span class="punctuation">,</span><span class="literal number integer">4</span><span class="punctuation">))</span> <span class="operator">*</span> <span class="punctuation">(</span><span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">)</span>
<span class="comment single"># Alpha color channel goes from 0 (transparent) to 1 (opaque)</span>
<span class="name">C</span><span class="punctuation">[:,</span><span class="literal number integer">3</span><span class="punctuation">]</span> <span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">linspace</span><span class="punctuation">(</span><span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">,</span><span class="name">n</span><span class="punctuation">)</span>

<span class="comment single"># Ring sizes</span>
<span class="name">S</span> <span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">linspace</span><span class="punctuation">(</span><span class="name">size_min</span><span class="punctuation">,</span> <span class="name">size_max</span><span class="punctuation">,</span> <span class="name">n</span><span class="punctuation">)</span>

<span class="comment single"># Scatter plot</span>
<span class="name">scat</span> <span class="operator">=</span> <span class="name">ax</span><span class="operator">.</span><span class="name">scatter</span><span class="punctuation">(</span><span class="name">P</span><span class="punctuation">[:,</span><span class="literal number integer">0</span><span class="punctuation">],</span> <span class="name">P</span><span class="punctuation">[:,</span><span class="literal number integer">1</span><span class="punctuation">],</span> <span class="name">s</span><span class="operator">=</span><span class="name">S</span><span class="punctuation">,</span> <span class="name">lw</span> <span class="operator">=</span> <span class="literal number float">0.5</span><span class="punctuation">,</span>
                  <span class="name">edgecolors</span> <span class="operator">=</span> <span class="name">C</span><span class="punctuation">,</span> <span class="name">facecolors</span><span class="operator">=</span><span class="literal string single">'None'</span><span class="punctuation">)</span>

<span class="comment single"># Ensure limits are [0,1] and remove ticks</span>
<span class="name">ax</span><span class="operator">.</span><span class="name">set_xlim</span><span class="punctuation">(</span><span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">),</span> <span class="name">ax</span><span class="operator">.</span><span class="name">set_xticks</span><span class="punctuation">([])</span>
<span class="name">ax</span><span class="operator">.</span><span class="name">set_ylim</span><span class="punctuation">(</span><span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">),</span> <span class="name">ax</span><span class="operator">.</span><span class="name">set_yticks</span><span class="punctuation">([])</span>
</pre>
<p>Now, we need to write the update function for our animation. We know that at
each time step each ring should grow be more transparent while largest ring
should be totally transparent and thus removed. Of course, we won't actually
remove the largest ring but re-use it to set a new ring at a new random
position, with nominal size and color. Hence, we keep the number of ring
constant.</p>
<a class="reference external image-reference" href="scripts/rain-dynamic.py"><img alt="figures/rain.gif" class="align-right" src="figures/rain.gif" /></a>
<pre class="code python literal-block">
<span class="keyword">def</span> <span class="name function">update</span><span class="punctuation">(</span><span class="name">frame</span><span class="punctuation">):</span>
    <span class="keyword">global</span> <span class="name">P</span><span class="punctuation">,</span> <span class="name">C</span><span class="punctuation">,</span> <span class="name">S</span>

    <span class="comment single"># Every ring is made more transparent</span>
    <span class="name">C</span><span class="punctuation">[:,</span><span class="literal number integer">3</span><span class="punctuation">]</span> <span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">maximum</span><span class="punctuation">(</span><span class="literal number integer">0</span><span class="punctuation">,</span> <span class="name">C</span><span class="punctuation">[:,</span><span class="literal number integer">3</span><span class="punctuation">]</span> <span class="operator">-</span> <span class="literal number float">1.0</span><span class="operator">/</span><span class="name">n</span><span class="punctuation">)</span>

    <span class="comment single"># Each ring is made larger</span>
    <span class="name">S</span> <span class="operator">+=</span> <span class="punctuation">(</span><span class="name">size_max</span> <span class="operator">-</span> <span class="name">size_min</span><span class="punctuation">)</span> <span class="operator">/</span> <span class="name">n</span>

    <span class="comment single"># Reset ring specific ring (relative to frame number)</span>
    <span class="name">i</span> <span class="operator">=</span> <span class="name">frame</span> <span class="operator">%</span> <span class="literal number integer">50</span>
    <span class="name">P</span><span class="punctuation">[</span><span class="name">i</span><span class="punctuation">]</span> <span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">random</span><span class="operator">.</span><span class="name">uniform</span><span class="punctuation">(</span><span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">,</span><span class="literal number integer">2</span><span class="punctuation">)</span>
    <span class="name">S</span><span class="punctuation">[</span><span class="name">i</span><span class="punctuation">]</span> <span class="operator">=</span> <span class="name">size_min</span>
    <span class="name">C</span><span class="punctuation">[</span><span class="name">i</span><span class="punctuation">,</span><span class="literal number integer">3</span><span class="punctuation">]</span> <span class="operator">=</span> <span class="literal number integer">1</span>

    <span class="comment single"># Update scatter object</span>
    <span class="name">scat</span><span class="operator">.</span><span class="name">set_edgecolors</span><span class="punctuation">(</span><span class="name">C</span><span class="punctuation">)</span>
    <span class="name">scat</span><span class="operator">.</span><span class="name">set_sizes</span><span class="punctuation">(</span><span class="name">S</span><span class="punctuation">)</span>
    <span class="name">scat</span><span class="operator">.</span><span class="name">set_offsets</span><span class="punctuation">(</span><span class="name">P</span><span class="punctuation">)</span>

    <span class="comment single"># Return the modified object</span>
    <span class="keyword">return</span> <span class="name">scat</span><span class="punctuation">,</span>
</pre>
<p>Last step is to tell matplotlib to use this function as an update function for
the animation and display the result or save it as a movie:</p>
<pre class="code python literal-block">
<span class="name">animation</span> <span class="operator">=</span> <span class="name">FuncAnimation</span><span class="punctuation">(</span><span class="name">fig</span><span class="punctuation">,</span> <span class="name">update</span><span class="punctuation">,</span> <span class="name">interval</span><span class="operator">=</span><span class="literal number integer">10</span><span class="punctuation">,</span> <span class="name">blit</span><span class="operator">=</span><span class="name builtin pseudo">True</span><span class="punctuation">,</span> <span class="name">frames</span><span class="operator">=</span><span class="literal number integer">200</span><span class="punctuation">)</span>
<span class="comment single"># animation.save('rain.gif', writer='imagemagick', fps=30, dpi=40)</span>
<span class="name">plt</span><span class="operator">.</span><span class="name">show</span><span class="punctuation">()</span>
</pre>
</div>
<div class="section" id="earthquakes">
<h2>Earthquakes</h2>
<p>We'll now use the rain animation to visualize earthquakes on the planet from
the last 30 days. The USGS Earthquake Hazards Program is part of the National
Earthquake Hazards Reduction Program (NEHRP) and provides several data on their
<a class="reference external" href="http://earthquake.usgs.gov">website</a>. Those data are sorted according to
earthquakes magnitude, ranging from significant only down to all earthquakes,
major or minor. You would be surprised by the number of minor earthquakes
happening every hour on the planet. Since this would represent too much data
for us, we'll stick to earthquakes with magnitude &gt; 4.5. At the time of writing,
this already represent more than 300 earthquakes in the last 30 days.</p>
<p>First step is to read and convert data. We'll use the <cite>urllib</cite> library that
allows to open and read remote data. Data on the website use the <cite>CSV</cite> format
whose content is given by the first line:</p>
<pre class="literal-block">
time,latitude,longitude,depth,mag,magType,nst,gap,dmin,rms,net,id,updated,place,type
2015-08-17T13:49:17.320Z,37.8365,-122.2321667,4.82,4.01,mw,...
2015-08-15T07:47:06.640Z,-10.9045,163.8766,6.35,6.6,mwp,...
</pre>
<p>We are only interested in latitude, longitude and magnitude and we won't parse
time of event (ok, that's bad, feel free to send me a PR).</p>
<pre class="code python literal-block">
<span class="keyword namespace">import</span> <span class="name namespace">urllib</span>
<span class="keyword namespace">from</span> <span class="name namespace">mpl_toolkits.basemap</span> <span class="keyword namespace">import</span> <span class="name">Basemap</span>

<span class="comment single"># -&gt; http://earthquake.usgs.gov/earthquakes/feed/v1.0/csv.php</span>
<span class="name">feed</span> <span class="operator">=</span> <span class="literal string double">&quot;http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/&quot;</span>

<span class="comment single"># Significant earthquakes in the last 30 days</span>
<span class="comment single"># url = urllib.request.urlopen(feed + &quot;significant_month.csv&quot;)</span>

<span class="comment single"># Magnitude &gt; 4.5</span>
<span class="name">url</span> <span class="operator">=</span> <span class="name">urllib</span><span class="operator">.</span><span class="name">request</span><span class="operator">.</span><span class="name">urlopen</span><span class="punctuation">(</span><span class="name">feed</span> <span class="operator">+</span> <span class="literal string double">&quot;4.5_month.csv&quot;</span><span class="punctuation">)</span>

<span class="comment single"># Magnitude &gt; 2.5</span>
<span class="comment single"># url = urllib.request.urlopen(feed + &quot;2.5_month.csv&quot;)</span>

<span class="comment single"># Magnitude &gt; 1.0</span>
<span class="comment single"># url = urllib.request.urlopen(feed + &quot;1.0_month.csv&quot;)</span>

<span class="comment single"># Reading and storage of data</span>
<span class="name">data</span> <span class="operator">=</span> <span class="name">url</span><span class="operator">.</span><span class="name">read</span><span class="punctuation">()</span>
<span class="name">data</span> <span class="operator">=</span> <span class="name">data</span><span class="operator">.</span><span class="name">split</span><span class="punctuation">(</span><span class="name">b</span><span class="literal string single">'</span><span class="literal string escape">\n</span><span class="literal string single">'</span><span class="punctuation">)[</span><span class="operator">+</span><span class="literal number integer">1</span><span class="punctuation">:</span><span class="operator">-</span><span class="literal number integer">1</span><span class="punctuation">]</span>
<span class="name">E</span> <span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">zeros</span><span class="punctuation">(</span><span class="name builtin">len</span><span class="punctuation">(</span><span class="name">data</span><span class="punctuation">),</span> <span class="name">dtype</span><span class="operator">=</span><span class="punctuation">[(</span><span class="literal string single">'position'</span><span class="punctuation">,</span>  <span class="name builtin">float</span><span class="punctuation">,</span> <span class="literal number integer">2</span><span class="punctuation">),</span>
                               <span class="punctuation">(</span><span class="literal string single">'magnitude'</span><span class="punctuation">,</span> <span class="name builtin">float</span><span class="punctuation">,</span> <span class="literal number integer">1</span><span class="punctuation">)])</span>

<span class="keyword">for</span> <span class="name">i</span> <span class="operator word">in</span> <span class="name builtin">range</span><span class="punctuation">(</span><span class="name builtin">len</span><span class="punctuation">(</span><span class="name">data</span><span class="punctuation">)):</span>
    <span class="name">row</span> <span class="operator">=</span> <span class="name">data</span><span class="punctuation">[</span><span class="name">i</span><span class="punctuation">]</span><span class="operator">.</span><span class="name">split</span><span class="punctuation">(</span><span class="literal string single">','</span><span class="punctuation">)</span>
    <span class="name">E</span><span class="punctuation">[</span><span class="literal string single">'position'</span><span class="punctuation">][</span><span class="name">i</span><span class="punctuation">]</span> <span class="operator">=</span> <span class="name builtin">float</span><span class="punctuation">(</span><span class="name">row</span><span class="punctuation">[</span><span class="literal number integer">2</span><span class="punctuation">]),</span><span class="name builtin">float</span><span class="punctuation">(</span><span class="name">row</span><span class="punctuation">[</span><span class="literal number integer">1</span><span class="punctuation">])</span>
    <span class="name">E</span><span class="punctuation">[</span><span class="literal string single">'magnitude'</span><span class="punctuation">][</span><span class="name">i</span><span class="punctuation">]</span> <span class="operator">=</span> <span class="name builtin">float</span><span class="punctuation">(</span><span class="name">row</span><span class="punctuation">[</span><span class="literal number integer">4</span><span class="punctuation">])</span>
</pre>
<p>Now, we need to draw earth on a figure to show precisely where the earthquake
center is and to translate latitude/longitude in some coordinates matplotlib
can handle. Fortunately, there is the <a class="reference external" href="http://matplotlib.org/basemap/">basemap</a> project (that tends to be replaced by the
more complete <a class="reference external" href="http://scitools.org.uk/cartopy/">cartopy</a>) that is really
simple to install and to use. First step is to define a projection to draw the
earth onto a screen (there exists many different projections) and we'll stick
to the <cite>mill</cite> projection which is rather standard for non-specialist like me.</p>
<pre class="code python literal-block">
<span class="name">fig</span> <span class="operator">=</span> <span class="name">plt</span><span class="operator">.</span><span class="name">figure</span><span class="punctuation">(</span><span class="name">figsize</span><span class="operator">=</span><span class="punctuation">(</span><span class="literal number integer">14</span><span class="punctuation">,</span><span class="literal number integer">10</span><span class="punctuation">))</span>
<span class="name">ax</span> <span class="operator">=</span> <span class="name">plt</span><span class="operator">.</span><span class="name">subplot</span><span class="punctuation">(</span><span class="literal number integer">1</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">)</span>

<span class="name">earth</span> <span class="operator">=</span> <span class="name">Basemap</span><span class="punctuation">(</span><span class="name">projection</span><span class="operator">=</span><span class="literal string single">'mill'</span><span class="punctuation">)</span>
</pre>
<p>Next, we request to draw coastline and fill continents:</p>
<pre class="code python literal-block">
<span class="name">earth</span><span class="operator">.</span><span class="name">drawcoastlines</span><span class="punctuation">(</span><span class="name">color</span><span class="operator">=</span><span class="literal string single">'0.50'</span><span class="punctuation">,</span> <span class="name">linewidth</span><span class="operator">=</span><span class="literal number float">0.25</span><span class="punctuation">)</span>
<span class="name">earth</span><span class="operator">.</span><span class="name">fillcontinents</span><span class="punctuation">(</span><span class="name">color</span><span class="operator">=</span><span class="literal string single">'0.95'</span><span class="punctuation">)</span>
</pre>
<p>The <cite>earth</cite> object will also be used to translate coordinate quite
automatically. We are almost finished. Last step is to adapt the rain code and
put some eye candy:</p>
<pre class="code python literal-block">
<span class="name">P</span> <span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">zeros</span><span class="punctuation">(</span><span class="literal number integer">50</span><span class="punctuation">,</span> <span class="name">dtype</span><span class="operator">=</span><span class="punctuation">[(</span><span class="literal string single">'position'</span><span class="punctuation">,</span> <span class="name builtin">float</span><span class="punctuation">,</span> <span class="literal number integer">2</span><span class="punctuation">),</span>
                         <span class="punctuation">(</span><span class="literal string single">'size'</span><span class="punctuation">,</span>     <span class="name builtin">float</span><span class="punctuation">,</span> <span class="literal number integer">1</span><span class="punctuation">),</span>
                         <span class="punctuation">(</span><span class="literal string single">'growth'</span><span class="punctuation">,</span>   <span class="name builtin">float</span><span class="punctuation">,</span> <span class="literal number integer">1</span><span class="punctuation">),</span>
                         <span class="punctuation">(</span><span class="literal string single">'color'</span><span class="punctuation">,</span>    <span class="name builtin">float</span><span class="punctuation">,</span> <span class="literal number integer">4</span><span class="punctuation">)])</span>
<span class="name">scat</span> <span class="operator">=</span> <span class="name">ax</span><span class="operator">.</span><span class="name">scatter</span><span class="punctuation">(</span><span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'position'</span><span class="punctuation">][:,</span><span class="literal number integer">0</span><span class="punctuation">],</span> <span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'position'</span><span class="punctuation">][:,</span><span class="literal number integer">1</span><span class="punctuation">],</span> <span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'size'</span><span class="punctuation">],</span> <span class="name">lw</span><span class="operator">=</span><span class="literal number float">0.5</span><span class="punctuation">,</span>
                  <span class="name">edgecolors</span> <span class="operator">=</span> <span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'color'</span><span class="punctuation">],</span> <span class="name">facecolors</span><span class="operator">=</span><span class="literal string single">'None'</span><span class="punctuation">,</span> <span class="name">zorder</span><span class="operator">=</span><span class="literal number integer">10</span><span class="punctuation">)</span>

<span class="keyword">def</span> <span class="name function">update</span><span class="punctuation">(</span><span class="name">frame</span><span class="punctuation">):</span>
    <span class="name">current</span> <span class="operator">=</span> <span class="name">frame</span> <span class="operator">%</span> <span class="name builtin">len</span><span class="punctuation">(</span><span class="name">E</span><span class="punctuation">)</span>
    <span class="name">i</span> <span class="operator">=</span> <span class="name">frame</span> <span class="operator">%</span> <span class="name builtin">len</span><span class="punctuation">(</span><span class="name">P</span><span class="punctuation">)</span>

    <span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'color'</span><span class="punctuation">][:,</span><span class="literal number integer">3</span><span class="punctuation">]</span> <span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">maximum</span><span class="punctuation">(</span><span class="literal number integer">0</span><span class="punctuation">,</span> <span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'color'</span><span class="punctuation">][:,</span><span class="literal number integer">3</span><span class="punctuation">]</span> <span class="operator">-</span> <span class="literal number float">1.0</span><span class="operator">/</span><span class="name builtin">len</span><span class="punctuation">(</span><span class="name">P</span><span class="punctuation">))</span>
    <span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'size'</span><span class="punctuation">]</span> <span class="operator">+=</span> <span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'growth'</span><span class="punctuation">]</span>

    <span class="name">magnitude</span> <span class="operator">=</span> <span class="name">E</span><span class="punctuation">[</span><span class="literal string single">'magnitude'</span><span class="punctuation">][</span><span class="name">current</span><span class="punctuation">]</span>
    <span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'position'</span><span class="punctuation">][</span><span class="name">i</span><span class="punctuation">]</span> <span class="operator">=</span> <span class="name">earth</span><span class="punctuation">(</span><span class="operator">*</span><span class="name">E</span><span class="punctuation">[</span><span class="literal string single">'position'</span><span class="punctuation">][</span><span class="name">current</span><span class="punctuation">])</span>
    <span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'size'</span><span class="punctuation">][</span><span class="name">i</span><span class="punctuation">]</span> <span class="operator">=</span> <span class="literal number integer">5</span>
    <span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'growth'</span><span class="punctuation">][</span><span class="name">i</span><span class="punctuation">]</span><span class="operator">=</span> <span class="name">np</span><span class="operator">.</span><span class="name">exp</span><span class="punctuation">(</span><span class="name">magnitude</span><span class="punctuation">)</span> <span class="operator">*</span> <span class="literal number float">0.1</span>

    <span class="keyword">if</span> <span class="name">magnitude</span> <span class="operator">&lt;</span> <span class="literal number integer">6</span><span class="punctuation">:</span>
        <span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'color'</span><span class="punctuation">][</span><span class="name">i</span><span class="punctuation">]</span>    <span class="operator">=</span> <span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">,</span><span class="literal number integer">1</span>
    <span class="keyword">else</span><span class="punctuation">:</span>
        <span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'color'</span><span class="punctuation">][</span><span class="name">i</span><span class="punctuation">]</span>    <span class="operator">=</span> <span class="literal number integer">1</span><span class="punctuation">,</span><span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">0</span><span class="punctuation">,</span><span class="literal number integer">1</span>
    <span class="name">scat</span><span class="operator">.</span><span class="name">set_edgecolors</span><span class="punctuation">(</span><span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'color'</span><span class="punctuation">])</span>
    <span class="name">scat</span><span class="operator">.</span><span class="name">set_facecolors</span><span class="punctuation">(</span><span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'color'</span><span class="punctuation">]</span><span class="operator">*</span><span class="punctuation">(</span><span class="literal number integer">1</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">,</span><span class="literal number integer">1</span><span class="punctuation">,</span><span class="literal number float">0.25</span><span class="punctuation">))</span>
    <span class="name">scat</span><span class="operator">.</span><span class="name">set_sizes</span><span class="punctuation">(</span><span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'size'</span><span class="punctuation">])</span>
    <span class="name">scat</span><span class="operator">.</span><span class="name">set_offsets</span><span class="punctuation">(</span><span class="name">P</span><span class="punctuation">[</span><span class="literal string single">'position'</span><span class="punctuation">])</span>
    <span class="keyword">return</span> <span class="name">scat</span><span class="punctuation">,</span>


<span class="name">animation</span> <span class="operator">=</span> <span class="name">FuncAnimation</span><span class="punctuation">(</span><span class="name">fig</span><span class="punctuation">,</span> <span class="name">update</span><span class="punctuation">,</span> <span class="name">interval</span><span class="operator">=</span><span class="literal number integer">10</span><span class="punctuation">)</span>
<span class="name">plt</span><span class="operator">.</span><span class="name">show</span><span class="punctuation">()</span>
</pre>
<p>If everything went well, you should obtain something like this (with animation):</p>
<a class="reference external image-reference" href="scripts/earthquakes.py"><img alt="figures/earthquakes.png" src="figures/earthquakes.png" style="width: 50%;" /></a>
</div>
</div>
<div class="section" id="other-types-of-plots">
<h1><a class="toc-backref" href="#id8">Other Types of Plots</a></h1>
<a class="reference internal image-reference" href="#regular-plots"><img alt="figures/plot.png" src="figures/plot.png" /></a>
<a class="reference internal image-reference" href="#scatter-plots"><img alt="figures/scatter.png" src="figures/scatter.png" /></a>
<a class="reference internal image-reference" href="#bar-plots"><img alt="figures/bar.png" src="figures/bar.png" /></a>
<a class="reference internal image-reference" href="#contour-plots"><img alt="figures/contour.png" src="figures/contour.png" /></a>
<a class="reference internal image-reference" href="#imshow"><img alt="figures/imshow.png" src="figures/imshow.png" /></a>
<a class="reference internal image-reference" href="#quiver-plots"><img alt="figures/quiver.png" src="figures/quiver.png" /></a>
<a class="reference internal image-reference" href="#pie-charts"><img alt="figures/pie.png" src="figures/pie.png" /></a>
<a class="reference internal image-reference" href="#grids"><img alt="figures/grid.png" src="figures/grid.png" /></a>
<a class="reference internal image-reference" href="#multi-plots"><img alt="figures/multiplot.png" src="figures/multiplot.png" /></a>
<a class="reference internal image-reference" href="#polar-axis"><img alt="figures/polar.png" src="figures/polar.png" /></a>
<a class="reference internal image-reference" href="#d-plots"><img alt="figures/plot3d.png" src="figures/plot3d.png" /></a>
<a class="reference internal image-reference" href="#text"><img alt="figures/text.png" src="figures/text.png" /></a>
<div class="section" id="regular-plots">
<h2>Regular Plots</h2>
<a class="reference external image-reference" href="scripts/plot_ex.py"><img alt="figures/plot_ex.png" class="align-right" src="figures/plot_ex.png" /></a>
<div class="admonition-hints admonition">
<p class="first admonition-title">Hints</p>
<p class="last">You need to use the <a class="reference external" href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.fill_between">fill_between</a>
command.</p>
</div>
<p>Starting from the code below, try to reproduce the graphic on the right taking
care of filled areas:</p>
<pre class="literal-block">
import numpy as np
import matplotlib.pyplot as plt

n = 256
X = np.linspace(-np.pi,np.pi,n,endpoint=True)
Y = np.sin(2*X)

plt.plot (X, Y+1, color='blue', alpha=1.00)
plt.plot (X, Y-1, color='blue', alpha=1.00)
plt.show()
</pre>
<p>Click on figure for solution.</p>
</div>
<div class="section" id="scatter-plots">
<h2>Scatter Plots</h2>
<a class="reference external image-reference" href="scripts/scatter_ex.py"><img alt="figures/scatter_ex.png" class="align-right" src="figures/scatter_ex.png" /></a>
<div class="admonition-hints admonition">
<p class="first admonition-title">Hints</p>
<p class="last">Color is given by angle of (X,Y).</p>
</div>
<p>Starting from the code below, try to reproduce the graphic on the right taking
care of marker size, color and transparency.</p>
<pre class="literal-block">
import numpy as np
import matplotlib.pyplot as plt

n = 1024
X = np.random.normal(0,1,n)
Y = np.random.normal(0,1,n)

plt.scatter(X,Y)
plt.show()
</pre>
<p>Click on figure for solution.</p>
</div>
<div class="section" id="bar-plots">
<h2>Bar Plots</h2>
<a class="reference external image-reference" href="scripts/bar_ex.py"><img alt="figures/bar_ex.png" class="align-right" src="figures/bar_ex.png" /></a>
<div class="admonition-hints admonition">
<p class="first admonition-title">Hints</p>
<p class="last">You need to take care of text alignment.</p>
</div>
<p>Starting from the code below, try to reproduce the graphic on the right by
adding labels for red bars.</p>
<pre class="literal-block">
import numpy as np
import matplotlib.pyplot as plt

n = 12
X = np.arange(n)
Y1 = (1-X/float(n)) * np.random.uniform(0.5,1.0,n)
Y2 = (1-X/float(n)) * np.random.uniform(0.5,1.0,n)

plt.bar(X, +Y1, facecolor='#9999ff', edgecolor='white')
plt.bar(X, -Y2, facecolor='#ff9999', edgecolor='white')

for x,y in zip(X,Y1):
    plt.text(x+0.4, y+0.05, '%.2f' % y, ha='center', va= 'bottom')

plt.ylim(-1.25,+1.25)
plt.show()
</pre>
<p>Click on figure for solution.</p>
</div>
<div class="section" id="contour-plots">
<h2>Contour Plots</h2>
<a class="reference external image-reference" href="scripts/contour_ex.py"><img alt="figures/contour_ex.png" class="align-right" src="figures/contour_ex.png" /></a>
<div class="admonition-hints admonition">
<p class="first admonition-title">Hints</p>
<p class="last">You need to use the <a class="reference external" href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.clabel">clabel</a>
command.</p>
</div>
<p>Starting from the code below, try to reproduce the graphic on the right taking
care of the colormap (see <a class="reference internal" href="#colormaps">Colormaps</a> below).</p>
<pre class="literal-block">
import numpy as np
import matplotlib.pyplot as plt

def f(x,y): return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2)

n = 256
x = np.linspace(-3,3,n)
y = np.linspace(-3,3,n)
X,Y = np.meshgrid(x,y)

plt.contourf(X, Y, f(X,Y), 8, alpha=.75, cmap='jet')
C = plt.contour(X, Y, f(X,Y), 8, colors='black', linewidth=.5)
plt.show()
</pre>
<p>Click on figure for solution.</p>
</div>
<div class="section" id="imshow">
<h2>Imshow</h2>
<a class="reference external image-reference" href="scripts/imshow_ex.py"><img alt="figures/imshow_ex.png" class="align-right" src="figures/imshow_ex.png" /></a>
<div class="admonition-hints admonition">
<p class="first admonition-title">Hints</p>
<p class="last">You need to take care of the <tt class="docutils literal">origin</tt> of the image in the imshow command and
use a <a class="reference external" href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.colorbar">colorbar</a></p>
</div>
<p>Starting from the code below, try to reproduce the graphic on the right taking
care of colormap, image interpolation and origin.</p>
<pre class="literal-block">
import numpy as np
import matplotlib.pyplot as plt

def f(x,y): return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2)

n = 10
x = np.linspace(-3,3,4*n)
y = np.linspace(-3,3,3*n)
X,Y = np.meshgrid(x,y)
plt.imshow(f(X,Y))
plt.show()
</pre>
<p>Click on figure for solution.</p>
</div>
<div class="section" id="pie-charts">
<h2>Pie Charts</h2>
<a class="reference external image-reference" href="scripts/pie_ex.py"><img alt="figures/pie_ex.png" class="align-right" src="figures/pie_ex.png" /></a>
<div class="admonition-hints admonition">
<p class="first admonition-title">Hints</p>
<p class="last">You need to modify Z.</p>
</div>
<p>Starting from the code below, try to reproduce the graphic on the right taking
care of colors and slices size.</p>
<pre class="literal-block">
import numpy as np
import matplotlib.pyplot as plt

n = 20
Z = np.random.uniform(0,1,n)
plt.pie(Z)
plt.show()
</pre>
<p>Click on figure for solution.</p>
</div>
<div class="section" id="quiver-plots">
<h2>Quiver Plots</h2>
<a class="reference external image-reference" href="scripts/quiver_ex.py"><img alt="figures/quiver_ex.png" class="align-right" src="figures/quiver_ex.png" /></a>
<div class="admonition-hints admonition">
<p class="first admonition-title">Hints</p>
<p class="last">You need to draw arrows twice.</p>
</div>
<p>Starting from the code above, try to reproduce the graphic on the right taking
care of colors and orientations.</p>
<pre class="literal-block">
import numpy as np
import matplotlib.pyplot as plt

n = 8
X,Y = np.mgrid[0:n,0:n]
plt.quiver(X,Y)
plt.show()
</pre>
<p>Click on figure for solution.</p>
</div>
<div class="section" id="grids">
<h2>Grids</h2>
<a class="reference external image-reference" href="scripts/grid_ex.py"><img alt="figures/grid_ex.png" class="align-right" src="figures/grid_ex.png" /></a>
<p>Starting from the code below, try to reproduce the graphic on the right taking
care of line styles.</p>
<pre class="literal-block">
import numpy as np
import matplotlib.pyplot as plt

axes = gca()
axes.set_xlim(0,4)
axes.set_ylim(0,3)
axes.set_xticklabels([])
axes.set_yticklabels([])

plt.show()
</pre>
<p>Click on figure for solution.</p>
</div>
<div class="section" id="multi-plots">
<h2>Multi Plots</h2>
<a class="reference external image-reference" href="scripts/multiplot_ex.py"><img alt="figures/multiplot_ex.png" class="align-right" src="figures/multiplot_ex.png" /></a>
<div class="admonition-hints admonition">
<p class="first admonition-title">Hints</p>
<p class="last">You can use several subplots with different partition.</p>
</div>
<p>Starting from the code below, try to reproduce the graphic on the right.</p>
<pre class="literal-block">
import numpy as np
import matplotlib.pyplot as plt

plt.subplot(2,2,1)
plt.subplot(2,2,3)
plt.subplot(2,2,4)

plt.show()
</pre>
<p>Click on figure for solution.</p>
</div>
<div class="section" id="polar-axis">
<h2>Polar Axis</h2>
<a class="reference external image-reference" href="scripts/polar_ex.py"><img alt="figures/polar_ex.png" class="align-right" src="figures/polar_ex.png" /></a>
<div class="admonition-hints admonition">
<p class="first admonition-title">Hints</p>
<p class="last">You only need to modify the <tt class="docutils literal">axes</tt> line</p>
</div>
<p>Starting from the code below, try to reproduce the graphic on the right.</p>
<pre class="literal-block">
import numpy as np
import matplotlib.pyplot as plt

plt.axes([0,0,1,1])

N = 20
theta = np.arange(0.0, 2*np.pi, 2*np.pi/N)
radii = 10*np.random.rand(N)
width = np.pi/4*np.random.rand(N)
bars = plt.bar(theta, radii, width=width, bottom=0.0)

for r,bar in zip(radii, bars):
    bar.set_facecolor( cm.jet(r/10.))
    bar.set_alpha(0.5)

plt.show()
</pre>
<p>Click on figure for solution.</p>
</div>
<div class="section" id="d-plots">
<h2>3D Plots</h2>
<a class="reference external image-reference" href="scripts/plot3d_ex.py"><img alt="figures/plot3d_ex.png" class="align-right" src="figures/plot3d_ex.png" /></a>
<div class="admonition-hints admonition">
<p class="first admonition-title">Hints</p>
<p class="last">You need to use <a class="reference external" href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.contourf">contourf</a></p>
</div>
<p>Starting from the code below, try to reproduce the graphic on the right.</p>
<pre class="literal-block">
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = Axes3D(fig)
X = np.arange(-4, 4, 0.25)
Y = np.arange(-4, 4, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)

ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='hot')

plt.show()
</pre>
<p>Click on figure for solution.</p>
</div>
<div class="section" id="text">
<h2>Text</h2>
<a class="reference external image-reference" href="scripts/text_ex.py"><img alt="figures/text_ex.png" class="align-right" src="figures/text_ex.png" /></a>
<div class="admonition-hints admonition">
<p class="first admonition-title">Hints</p>
<p class="last">Have a look at the <a class="reference external" href="http://matplotlib.sourceforge.net/examples/api/logo2.html">matplotlib logo</a>.</p>
</div>
<p>Try to do the same from scratch !</p>
<p>Click on figure for solution.</p>
</div>
</div>
<div class="section" id="beyond-this-tutorial">
<h1><a class="toc-backref" href="#id9">Beyond this tutorial</a></h1>
<p>Matplotlib benefits from extensive documentation as well as a large
community of users and developpers. Here are some links of interest:</p>
<div class="section" id="tutorials">
<h2>Tutorials</h2>
<ul class="simple">
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/pyplot_tutorial.html">Pyplot tutorial</a><ul>
<li>Introduction</li>
<li>Controlling line properties</li>
<li>Working with multiple figures and axes</li>
<li>Working with text</li>
<li></li>
</ul>
</li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/image_tutorial.html">Image tutorial</a><ul>
<li>Startup commands</li>
<li>Importing image data into Numpy arrays</li>
<li>Plotting numpy arrays as images</li>
<li></li>
</ul>
</li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/index_text.html">Text tutorial</a><ul>
<li>Text introduction</li>
<li>Basic text commands</li>
<li>Text properties and layout</li>
<li>Writing mathematical expressions</li>
<li>Text rendering With LaTeX</li>
<li>Annotating text</li>
<li></li>
</ul>
</li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/artists.html">Artist tutorial</a><ul>
<li>Introduction</li>
<li>Customizing your objects</li>
<li>Object containers</li>
<li>Figure container</li>
<li>Axes container</li>
<li>Axis containers</li>
<li>Tick containers</li>
<li></li>
</ul>
</li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/path_tutorial.html">Path tutorial</a><ul>
<li>Introduction</li>
<li>Bézier example</li>
<li>Compound paths</li>
<li></li>
</ul>
</li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/transforms_tutorial.html">Transforms tutorial</a><ul>
<li>Introduction</li>
<li>Data coordinates</li>
<li>Axes coordinates</li>
<li>Blended transformations</li>
<li>Using offset transforms to create a shadow effect</li>
<li>The transformation pipeline</li>
<li></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="matplotlib-documentation">
<h2>Matplotlib documentation</h2>
<ul class="simple">
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/index.html">User guide</a></li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/faq/index.html">FAQ</a><ul>
<li>Installation</li>
<li>Usage</li>
<li>How-To</li>
<li>Troubleshooting</li>
<li>Environment Variables</li>
<li></li>
</ul>
</li>
<li><a class="reference external" href="http://matplotlib.sourceforge.net/users/screenshots.html">Screenshots</a></li>
</ul>
</div>
<div class="section" id="code-documentation">
<h2>Code documentation</h2>
<p>The code is fairly well documented and you can quickly access a specific
command from within a python session:</p>
<pre class="literal-block">
&gt;&gt;&gt; import matplotlib.pyplot as plt
&gt;&gt;&gt; help(plt)
Help on function plot in module matplotlib.pyplot:

plot(*args, **kwargs)
   Plot lines and/or markers to the
   :class:`~matplotlib.axes.Axes`.  *args* is a variable length
   argument, allowing for multiple *x*, *y* pairs with an
   optional format string.  For example, each of the following is
   legal::

       plot(x, y)         # plot x and y using default line style and color
       plot(x, y, 'bo')   # plot x and y using blue circle markers
       plot(y)            # plot y using x as index array 0..N-1
       plot(y, 'r+')      # ditto, but with red plusses

   If *x* and/or *y* is 2-dimensional, then the corresponding columns
   will be plotted.
   ...
</pre>
</div>
<div class="section" id="galleries">
<h2>Galleries</h2>
<p>The <a class="reference external" href="http://matplotlib.sourceforge.net/gallery.html">matplotlib gallery</a> is
also incredibly useful when you search how to render a given graphic. Each
example comes with its source.</p>
<p>A smaller gallery is also available <a class="reference external" href="http://www.loria.fr/~rougier/coding/gallery/">here</a>.</p>
</div>
<div class="section" id="mailing-lists">
<h2>Mailing lists</h2>
<p>Finally, there is a <a class="reference external" href="https://mail.python.org/mailman/listinfo/matplotlib-users">user mailing list</a> where you can
ask for help and a <a class="reference external" href="https://mail.python.org/mailman/listinfo/matplotlib-devel">developers mailing list</a> that is more
technical.</p>
</div>
</div>
<div class="section" id="quick-references">
<h1><a class="toc-backref" href="#id10">Quick references</a></h1>
<p>Here is a set of tables that show main properties and styles.</p>
<div class="section" id="line-properties">
<h2>Line properties</h2>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="30%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Property</th>
<th class="head">Description</th>
<th class="head">Appearance</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>alpha (or a)</td>
<td>alpha transparency on 0-1 scale</td>
<td><img alt="figures/alpha.png" class="first last" src="figures/alpha.png" />
</td>
</tr>
<tr><td>antialiased</td>
<td>True or False - use antialised rendering</td>
<td><img alt="figures/aliased.png" class="first" src="figures/aliased.png" />
<img alt="figures/antialiased.png" class="last" src="figures/antialiased.png" />
</td>
</tr>
<tr><td>color (or c)</td>
<td>matplotlib color arg</td>
<td><img alt="figures/color.png" class="first last" src="figures/color.png" />
</td>
</tr>
<tr><td>linestyle (or ls)</td>
<td>see <a class="reference internal" href="#line-properties">Line properties</a></td>
<td>&nbsp;</td>
</tr>
<tr><td>linewidth (or lw)</td>
<td>float, the line width in points</td>
<td><img alt="figures/linewidth.png" class="first last" src="figures/linewidth.png" />
</td>
</tr>
<tr><td>solid_capstyle</td>
<td>Cap style for solid lines</td>
<td><img alt="figures/solid_capstyle.png" class="first last" src="figures/solid_capstyle.png" />
</td>
</tr>
<tr><td>solid_joinstyle</td>
<td>Join style for solid lines</td>
<td><img alt="figures/solid_joinstyle.png" class="first last" src="figures/solid_joinstyle.png" />
</td>
</tr>
<tr><td>dash_capstyle</td>
<td>Cap style for dashes</td>
<td><img alt="figures/dash_capstyle.png" class="first last" src="figures/dash_capstyle.png" />
</td>
</tr>
<tr><td>dash_joinstyle</td>
<td>Join style for dashes</td>
<td><img alt="figures/dash_joinstyle.png" class="first last" src="figures/dash_joinstyle.png" />
</td>
</tr>
<tr><td>marker</td>
<td>see <a class="reference internal" href="#markers">Markers</a></td>
<td>&nbsp;</td>
</tr>
<tr><td>markeredgewidth (mew)</td>
<td>line width around the marker symbol</td>
<td><img alt="figures/mew.png" class="first last" src="figures/mew.png" />
</td>
</tr>
<tr><td>markeredgecolor (mec)</td>
<td>edge color if a marker is used</td>
<td><img alt="figures/mec.png" class="first last" src="figures/mec.png" />
</td>
</tr>
<tr><td>markerfacecolor (mfc)</td>
<td>face color if a marker is used</td>
<td><img alt="figures/mfc.png" class="first last" src="figures/mfc.png" />
</td>
</tr>
<tr><td>markersize (ms)</td>
<td>size of the marker in points</td>
<td><img alt="figures/ms.png" class="first last" src="figures/ms.png" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="line-styles">
<h2>Line styles</h2>
<table border="1" class="docutils">
<colgroup>
<col width="16%" />
<col width="32%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Symbol</th>
<th class="head">Description</th>
<th class="head">Appearance</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="docutils literal">-</tt></td>
<td>solid line</td>
<td><img alt="figures/linestyle--.png" class="first last" src="figures/linestyle--.png" />
</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">--</span></tt></td>
<td>dashed line</td>
<td><img alt="figures/linestyle---.png" class="first last" src="figures/linestyle---.png" />
</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">-.</span></tt></td>
<td>dash-dot line</td>
<td><img alt="figures/linestyle--dot.png" class="first last" src="figures/linestyle--dot.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">:</tt></td>
<td>dotted line</td>
<td><img alt="figures/linestyle-:.png" class="first last" src="figures/linestyle-:.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">.</tt></td>
<td>points</td>
<td><img alt="figures/linestyle-dot.png" class="first last" src="figures/linestyle-dot.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">,</tt></td>
<td>pixels</td>
<td><img alt="figures/linestyle-,.png" class="first last" src="figures/linestyle-,.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">o</tt></td>
<td>circle</td>
<td><img alt="figures/linestyle-o.png" class="first last" src="figures/linestyle-o.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">^</tt></td>
<td>triangle up</td>
<td><img alt="figures/linestyle-^.png" class="first last" src="figures/linestyle-^.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">v</tt></td>
<td>triangle down</td>
<td><img alt="figures/linestyle-v.png" class="first last" src="figures/linestyle-v.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">&lt;</tt></td>
<td>triangle left</td>
<td><img alt="figures/linestyle-&lt;.png" class="first last" src="figures/linestyle-&lt;.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">&gt;</tt></td>
<td>triangle right</td>
<td><img alt="figures/linestyle-&gt;.png" class="first last" src="figures/linestyle-&gt;.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">s</tt></td>
<td>square</td>
<td><img alt="figures/linestyle-s.png" class="first last" src="figures/linestyle-s.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">+</tt></td>
<td>plus</td>
<td><img alt="figures/linestyle-+.png" class="first last" src="figures/linestyle-+.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">x</tt></td>
<td>cross</td>
<td><img alt="figures/linestyle-x.png" class="first last" src="figures/linestyle-x.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">D</tt></td>
<td>diamond</td>
<td><img alt="figures/linestyle-dd.png" class="first last" src="figures/linestyle-dd.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">d</tt></td>
<td>thin diamond</td>
<td><img alt="figures/linestyle-d.png" class="first last" src="figures/linestyle-d.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">1</tt></td>
<td>tripod down</td>
<td><img alt="figures/linestyle-1.png" class="first last" src="figures/linestyle-1.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">2</tt></td>
<td>tripod up</td>
<td><img alt="figures/linestyle-2.png" class="first last" src="figures/linestyle-2.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">3</tt></td>
<td>tripod left</td>
<td><img alt="figures/linestyle-3.png" class="first last" src="figures/linestyle-3.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">4</tt></td>
<td>tripod right</td>
<td><img alt="figures/linestyle-4.png" class="first last" src="figures/linestyle-4.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">h</tt></td>
<td>hexagon</td>
<td><img alt="figures/linestyle-h.png" class="first last" src="figures/linestyle-h.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">H</tt></td>
<td>rotated hexagon</td>
<td><img alt="figures/linestyle-hh.png" class="first last" src="figures/linestyle-hh.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">p</tt></td>
<td>pentagon</td>
<td><img alt="figures/linestyle-p.png" class="first last" src="figures/linestyle-p.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">|</tt></td>
<td>vertical line</td>
<td><img alt="figures/linestyle-|.png" class="first last" src="figures/linestyle-|.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">_</tt></td>
<td>horizontal line</td>
<td><img alt="figures/linestyle-_.png" class="first last" src="figures/linestyle-_.png" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="markers">
<h2>Markers</h2>
<table border="1" class="docutils">
<colgroup>
<col width="16%" />
<col width="32%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Symbol</th>
<th class="head">Description</th>
<th class="head">Appearance</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>0</td>
<td>tick left</td>
<td><img alt="figures/marker-i0.png" class="first last" src="figures/marker-i0.png" />
</td>
</tr>
<tr><td>1</td>
<td>tick right</td>
<td><img alt="figures/marker-i1.png" class="first last" src="figures/marker-i1.png" />
</td>
</tr>
<tr><td>2</td>
<td>tick up</td>
<td><img alt="figures/marker-i2.png" class="first last" src="figures/marker-i2.png" />
</td>
</tr>
<tr><td>3</td>
<td>tick down</td>
<td><img alt="figures/marker-i3.png" class="first last" src="figures/marker-i3.png" />
</td>
</tr>
<tr><td>4</td>
<td>caret left</td>
<td><img alt="figures/marker-i4.png" class="first last" src="figures/marker-i4.png" />
</td>
</tr>
<tr><td>5</td>
<td>caret right</td>
<td><img alt="figures/marker-i5.png" class="first last" src="figures/marker-i5.png" />
</td>
</tr>
<tr><td>6</td>
<td>caret up</td>
<td><img alt="figures/marker-i6.png" class="first last" src="figures/marker-i6.png" />
</td>
</tr>
<tr><td>7</td>
<td>caret down</td>
<td><img alt="figures/marker-i7.png" class="first last" src="figures/marker-i7.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">o</tt></td>
<td>circle</td>
<td><img alt="figures/marker-o.png" class="first last" src="figures/marker-o.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">D</tt></td>
<td>diamond</td>
<td><img alt="figures/marker-dd.png" class="first last" src="figures/marker-dd.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">h</tt></td>
<td>hexagon 1</td>
<td><img alt="figures/marker-h.png" class="first last" src="figures/marker-h.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">H</tt></td>
<td>hexagon 2</td>
<td><img alt="figures/marker-hh.png" class="first last" src="figures/marker-hh.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">_</tt></td>
<td>horizontal line</td>
<td><img alt="figures/marker-_.png" class="first last" src="figures/marker-_.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">1</tt></td>
<td>tripod down</td>
<td><img alt="figures/marker-1.png" class="first last" src="figures/marker-1.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">2</tt></td>
<td>tripod up</td>
<td><img alt="figures/marker-2.png" class="first last" src="figures/marker-2.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">3</tt></td>
<td>tripod left</td>
<td><img alt="figures/marker-3.png" class="first last" src="figures/marker-3.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">4</tt></td>
<td>tripod right</td>
<td><img alt="figures/marker-4.png" class="first last" src="figures/marker-4.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">8</tt></td>
<td>octagon</td>
<td><img alt="figures/marker-8.png" class="first last" src="figures/marker-8.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">p</tt></td>
<td>pentagon</td>
<td><img alt="figures/marker-p.png" class="first last" src="figures/marker-p.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">^</tt></td>
<td>triangle up</td>
<td><img alt="figures/marker-^.png" class="first last" src="figures/marker-^.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">v</tt></td>
<td>triangle down</td>
<td><img alt="figures/marker-v.png" class="first last" src="figures/marker-v.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">&lt;</tt></td>
<td>triangle left</td>
<td><img alt="figures/marker-&lt;.png" class="first last" src="figures/marker-&lt;.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">&gt;</tt></td>
<td>triangle right</td>
<td><img alt="figures/marker-&gt;.png" class="first last" src="figures/marker-&gt;.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">d</tt></td>
<td>thin diamond</td>
<td><img alt="figures/marker-d.png" class="first last" src="figures/marker-d.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">,</tt></td>
<td>pixel</td>
<td><img alt="figures/marker-,.png" class="first last" src="figures/marker-,.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">+</tt></td>
<td>plus</td>
<td><img alt="figures/marker-+.png" class="first last" src="figures/marker-+.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">.</tt></td>
<td>point</td>
<td><img alt="figures/marker-dot.png" class="first last" src="figures/marker-dot.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">s</tt></td>
<td>square</td>
<td><img alt="figures/marker-s.png" class="first last" src="figures/marker-s.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">*</tt></td>
<td>star</td>
<td><img alt="figures/marker-*.png" class="first last" src="figures/marker-*.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">|</tt></td>
<td>vertical line</td>
<td><img alt="figures/marker-|.png" class="first last" src="figures/marker-|.png" />
</td>
</tr>
<tr><td><tt class="docutils literal">x</tt></td>
<td>cross</td>
<td><img alt="figures/marker-x.png" class="first last" src="figures/marker-x.png" />
</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">r'$\sqrt{2}$'</span></tt></td>
<td>any latex expression</td>
<td><img alt="figures/marker-latex.png" class="first last" src="figures/marker-latex.png" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="colormaps">
<h2>Colormaps</h2>
<p>All colormaps can be reversed by appending <tt class="docutils literal">_r</tt>. For instance, <tt class="docutils literal">gray_r</tt> is
the reverse of <tt class="docutils literal">gray</tt>.</p>
<p>If you want to know more about colormaps, checks <a class="reference external" href="https://gist.github.com/2719900">Documenting the matplotlib
colormaps</a>.</p>
<div class="section" id="base">
<h3>Base</h3>
<table border="1" class="docutils">
<colgroup>
<col width="30%" />
<col width="70%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Name</th>
<th class="head">Appearance</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>autumn</td>
<td><img alt="figures/cmap-autumn.png" class="first last" src="figures/cmap-autumn.png" />
</td>
</tr>
<tr><td>bone</td>
<td><img alt="figures/cmap-bone.png" class="first last" src="figures/cmap-bone.png" />
</td>
</tr>
<tr><td>cool</td>
<td><img alt="figures/cmap-cool.png" class="first last" src="figures/cmap-cool.png" />
</td>
</tr>
<tr><td>copper</td>
<td><img alt="figures/cmap-copper.png" class="first last" src="figures/cmap-copper.png" />
</td>
</tr>
<tr><td>flag</td>
<td><img alt="figures/cmap-flag.png" class="first last" src="figures/cmap-flag.png" />
</td>
</tr>
<tr><td>gray</td>
<td><img alt="figures/cmap-gray.png" class="first last" src="figures/cmap-gray.png" />
</td>
</tr>
<tr><td>hot</td>
<td><img alt="figures/cmap-hot.png" class="first last" src="figures/cmap-hot.png" />
</td>
</tr>
<tr><td>hsv</td>
<td><img alt="figures/cmap-hsv.png" class="first last" src="figures/cmap-hsv.png" />
</td>
</tr>
<tr><td>jet</td>
<td><img alt="figures/cmap-jet.png" class="first last" src="figures/cmap-jet.png" />
</td>
</tr>
<tr><td>pink</td>
<td><img alt="figures/cmap-pink.png" class="first last" src="figures/cmap-pink.png" />
</td>
</tr>
<tr><td>prism</td>
<td><img alt="figures/cmap-prism.png" class="first last" src="figures/cmap-prism.png" />
</td>
</tr>
<tr><td>spectral</td>
<td><img alt="figures/cmap-spectral.png" class="first last" src="figures/cmap-spectral.png" />
</td>
</tr>
<tr><td>spring</td>
<td><img alt="figures/cmap-spring.png" class="first last" src="figures/cmap-spring.png" />
</td>
</tr>
<tr><td>summer</td>
<td><img alt="figures/cmap-summer.png" class="first last" src="figures/cmap-summer.png" />
</td>
</tr>
<tr><td>winter</td>
<td><img alt="figures/cmap-winter.png" class="first last" src="figures/cmap-winter.png" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="gist">
<h3>GIST</h3>
<table border="1" class="docutils">
<colgroup>
<col width="30%" />
<col width="70%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Name</th>
<th class="head">Appearance</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>gist_earth</td>
<td><img alt="figures/cmap-gist_earth.png" class="first last" src="figures/cmap-gist_earth.png" />
</td>
</tr>
<tr><td>gist_gray</td>
<td><img alt="figures/cmap-gist_gray.png" class="first last" src="figures/cmap-gist_gray.png" />
</td>
</tr>
<tr><td>gist_heat</td>
<td><img alt="figures/cmap-gist_heat.png" class="first last" src="figures/cmap-gist_heat.png" />
</td>
</tr>
<tr><td>gist_ncar</td>
<td><img alt="figures/cmap-gist_ncar.png" class="first last" src="figures/cmap-gist_ncar.png" />
</td>
</tr>
<tr><td>gist_rainbow</td>
<td><img alt="figures/cmap-gist_rainbow.png" class="first last" src="figures/cmap-gist_rainbow.png" />
</td>
</tr>
<tr><td>gist_stern</td>
<td><img alt="figures/cmap-gist_stern.png" class="first last" src="figures/cmap-gist_stern.png" />
</td>
</tr>
<tr><td>gist_yarg</td>
<td><img alt="figures/cmap-gist_yarg.png" class="first last" src="figures/cmap-gist_yarg.png" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="sequential">
<h3>Diverging</h3>
<table border="1" class="docutils">
<colgroup>
<col width="30%" />
<col width="70%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Name</th>
<th class="head">Appearance</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>BrBG</td>
<td><img alt="figures/cmap-BrBG.png" class="first last" src="figures/cmap-BrBG.png" />
</td>
</tr>
<tr><td>PiYG</td>
<td><img alt="figures/cmap-PiYG.png" class="first last" src="figures/cmap-PiYG.png" />
</td>
</tr>
<tr><td>PRGn</td>
<td><img alt="figures/cmap-PRGn.png" class="first last" src="figures/cmap-PRGn.png" />
</td>
</tr>
<tr><td>PuOr</td>
<td><img alt="figures/cmap-PuOr.png" class="first last" src="figures/cmap-PuOr.png" />
</td>
</tr>
<tr><td>RdBu</td>
<td><img alt="figures/cmap-RdBu.png" class="first last" src="figures/cmap-RdBu.png" />
</td>
</tr>
<tr><td>RdGy</td>
<td><img alt="figures/cmap-RdGy.png" class="first last" src="figures/cmap-RdGy.png" />
</td>
</tr>
<tr><td>RdYlBu</td>
<td><img alt="figures/cmap-RdYlBu.png" class="first last" src="figures/cmap-RdYlBu.png" />
</td>
</tr>
<tr><td>RdYlGn</td>
<td><img alt="figures/cmap-RdYlGn.png" class="first last" src="figures/cmap-RdYlGn.png" />
</td>
</tr>
<tr><td>Spectral</td>
<td><img alt="figures/cmap-spectral-2.png" class="first last" src="figures/cmap-spectral-2.png" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="diverging">
<h3>Sequential</h3>
<table border="1" class="docutils">
<colgroup>
<col width="30%" />
<col width="70%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Name</th>
<th class="head">Appearance</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>Blues</td>
<td><img alt="figures/cmap-Blues.png" class="first last" src="figures/cmap-Blues.png" />
</td>
</tr>
<tr><td>BuGn</td>
<td><img alt="figures/cmap-BuGn.png" class="first last" src="figures/cmap-BuGn.png" />
</td>
</tr>
<tr><td>BuPu</td>
<td><img alt="figures/cmap-BuPu.png" class="first last" src="figures/cmap-BuPu.png" />
</td>
</tr>
<tr><td>GnBu</td>
<td><img alt="figures/cmap-GnBu.png" class="first last" src="figures/cmap-GnBu.png" />
</td>
</tr>
<tr><td>Greens</td>
<td><img alt="figures/cmap-Greens.png" class="first last" src="figures/cmap-Greens.png" />
</td>
</tr>
<tr><td>Greys</td>
<td><img alt="figures/cmap-Greys.png" class="first last" src="figures/cmap-Greys.png" />
</td>
</tr>
<tr><td>Oranges</td>
<td><img alt="figures/cmap-Oranges.png" class="first last" src="figures/cmap-Oranges.png" />
</td>
</tr>
<tr><td>OrRd</td>
<td><img alt="figures/cmap-OrRd.png" class="first last" src="figures/cmap-OrRd.png" />
</td>
</tr>
<tr><td>PuBu</td>
<td><img alt="figures/cmap-PuBu.png" class="first last" src="figures/cmap-PuBu.png" />
</td>
</tr>
<tr><td>PuBuGn</td>
<td><img alt="figures/cmap-PuBuGn.png" class="first last" src="figures/cmap-PuBuGn.png" />
</td>
</tr>
<tr><td>PuRd</td>
<td><img alt="figures/cmap-PuRd.png" class="first last" src="figures/cmap-PuRd.png" />
</td>
</tr>
<tr><td>Purples</td>
<td><img alt="figures/cmap-Purples.png" class="first last" src="figures/cmap-Purples.png" />
</td>
</tr>
<tr><td>RdPu</td>
<td><img alt="figures/cmap-RdPu.png" class="first last" src="figures/cmap-RdPu.png" />
</td>
</tr>
<tr><td>Reds</td>
<td><img alt="figures/cmap-Reds.png" class="first last" src="figures/cmap-Reds.png" />
</td>
</tr>
<tr><td>YlGn</td>
<td><img alt="figures/cmap-YlGn.png" class="first last" src="figures/cmap-YlGn.png" />
</td>
</tr>
<tr><td>YlGnBu</td>
<td><img alt="figures/cmap-YlGnBu.png" class="first last" src="figures/cmap-YlGnBu.png" />
</td>
</tr>
<tr><td>YlOrBr</td>
<td><img alt="figures/cmap-YlOrBr.png" class="first last" src="figures/cmap-YlOrBr.png" />
</td>
</tr>
<tr><td>YlOrRd</td>
<td><img alt="figures/cmap-YlOrRd.png" class="first last" src="figures/cmap-YlOrRd.png" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="qualitative">
<h3>Qualitative</h3>
<table border="1" class="docutils">
<colgroup>
<col width="30%" />
<col width="70%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Name</th>
<th class="head">Appearance</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>Accent</td>
<td><img alt="figures/cmap-Accent.png" class="first last" src="figures/cmap-Accent.png" />
</td>
</tr>
<tr><td>Dark2</td>
<td><img alt="figures/cmap-Dark2.png" class="first last" src="figures/cmap-Dark2.png" />
</td>
</tr>
<tr><td>Paired</td>
<td><img alt="figures/cmap-Paired.png" class="first last" src="figures/cmap-Paired.png" />
</td>
</tr>
<tr><td>Pastel1</td>
<td><img alt="figures/cmap-Pastel1.png" class="first last" src="figures/cmap-Pastel1.png" />
</td>
</tr>
<tr><td>Pastel2</td>
<td><img alt="figures/cmap-Pastel2.png" class="first last" src="figures/cmap-Pastel2.png" />
</td>
</tr>
<tr><td>Set1</td>
<td><img alt="figures/cmap-Set1.png" class="first last" src="figures/cmap-Set1.png" />
</td>
</tr>
<tr><td>Set2</td>
<td><img alt="figures/cmap-Set2.png" class="first last" src="figures/cmap-Set2.png" />
</td>
</tr>
<tr><td>Set3</td>
<td><img alt="figures/cmap-Set3.png" class="first last" src="figures/cmap-Set3.png" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="miscellaneous">
<h3>Miscellaneous</h3>
<table border="1" class="docutils">
<colgroup>
<col width="30%" />
<col width="70%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Name</th>
<th class="head">Appearance</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>afmhot</td>
<td><img alt="figures/cmap-afmhot.png" class="first last" src="figures/cmap-afmhot.png" />
</td>
</tr>
<tr><td>binary</td>
<td><img alt="figures/cmap-binary.png" class="first last" src="figures/cmap-binary.png" />
</td>
</tr>
<tr><td>brg</td>
<td><img alt="figures/cmap-brg.png" class="first last" src="figures/cmap-brg.png" />
</td>
</tr>
<tr><td>bwr</td>
<td><img alt="figures/cmap-bwr.png" class="first last" src="figures/cmap-bwr.png" />
</td>
</tr>
<tr><td>coolwarm</td>
<td><img alt="figures/cmap-coolwarm.png" class="first last" src="figures/cmap-coolwarm.png" />
</td>
</tr>
<tr><td>CMRmap</td>
<td><img alt="figures/cmap-CMRmap.png" class="first last" src="figures/cmap-CMRmap.png" />
</td>
</tr>
<tr><td>cubehelix</td>
<td><img alt="figures/cmap-cubehelix.png" class="first last" src="figures/cmap-cubehelix.png" />
</td>
</tr>
<tr><td>gnuplot</td>
<td><img alt="figures/cmap-gnuplot.png" class="first last" src="figures/cmap-gnuplot.png" />
</td>
</tr>
<tr><td>gnuplot2</td>
<td><img alt="figures/cmap-gnuplot2.png" class="first last" src="figures/cmap-gnuplot2.png" />
</td>
</tr>
<tr><td>ocean</td>
<td><img alt="figures/cmap-ocean.png" class="first last" src="figures/cmap-ocean.png" />
</td>
</tr>
<tr><td>rainbow</td>
<td><img alt="figures/cmap-rainbow.png" class="first last" src="figures/cmap-rainbow.png" />
</td>
</tr>
<tr><td>seismic</td>
<td><img alt="figures/cmap-seismic.png" class="first last" src="figures/cmap-seismic.png" />
</td>
</tr>
<tr><td>terrain</td>
<td><img alt="figures/cmap-terrain.png" class="first last" src="figures/cmap-terrain.png" />
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</body>
</html>
